#include "Periferial.h"

extern unsigned long g_ulFlags;
extern int icounter;
extern unsigned long g_ulADCData;
extern unsigned long g_ulTimer2Count;
char Screen0[25]="|Tetris|";
int i=0,j=0,p=0;

void ScreenServer(void)
{
	icounter=0;
	g_ulTimer2Count=0;
	OSRAM96x16x1Clear();
	while(HWREGBITW(&g_ulFlags, FLAG_CLICK ) == 0)
	{	
		if(g_ulTimer2Count>25000)
		{
			OSRAM96x16x1DisplayOff();
			while(HWREGBITW(&g_ulFlags, FLAG_CLICK ) == 0)	{;}
			OSRAM96x16x1DisplayOn();
			g_ulTimer2Count=0;
			icounter=0;
			HWREGBITW(&g_ulFlags, FLAG_CLICK ) = 0;
		}	
		OSRAM96x16x1Clear();
		if(icounter==0)
		i=0;
	   	if(icounter==i)
		{
			i=icounter+1;
			j = ((TimerValueGet(TIMER0_BASE, TIMER_B )*(g_ulADCData+1)*icounter) % 48);
			p= ((TimerValueGet(TIMER0_BASE, TIMER_B )*(g_ulADCData+1)*icounter) % 2);

		}
		OSRAM96x16x1StringDraw( Screen0, j , p );
	}
	OSRAM96x16x1Clear();
}

